package com.etennis.controller;

import com.etennis.pojos.PageResult;
import com.etennis.pojos.ResponseResult;
import com.etennis.pojos.dto.web.PublicityDTO;
import com.etennis.pojos.dto.web.PublicityPageQueryDTO;
import com.etennis.pojos.vo.web.PublicityVO;
import com.etennis.service.INoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/web/publicity")
@Slf4j
@Api(tags = "网页端-公示管理接口")
public class PublicityController {
    @Autowired
    INoticeService iNoticeService;
    @PostMapping("/save")
    @ApiOperation("新增公示")
    public ResponseResult save(@RequestBody PublicityDTO publicityDTO){
        iNoticeService.savePublicity(publicityDTO);
        return ResponseResult.okResult();
    }
    @PutMapping("/update")
    @ApiOperation("修改公示")
    public ResponseResult update(@RequestBody PublicityDTO publicityDTO){
        iNoticeService.updatePublicity(publicityDTO);
        return ResponseResult.okResult();
    }
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除公示")
    public ResponseResult delete(@PathVariable Long id){
        iNoticeService.removeById(id);
        return ResponseResult.okResult();
    }
    @GetMapping("/page")
    @ApiOperation("分页展示公示")
    public ResponseResult<PageResult<PublicityVO>> page(PublicityPageQueryDTO pageQueryDTO){
        PageResult<PublicityVO> pageResult=iNoticeService.pagePublicity(pageQueryDTO);
        return ResponseResult.okResult(pageResult);
    }
}
